<template>
  <div class="nav">
    <el-menu
      :default-active="$route.path"
      class="el-menu-vertical-demo"
      :collapse="isCollapse"
      router
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b"
      unique-opened
    >
      <el-checkbox v-model="isCollapse">|||</el-checkbox>
      <el-submenu :index="item.path" v-for="(item, index) in navList" :key="index">
        <template slot="title">
          <i :class="arrLcon[index]"></i>
          <span slot="title">{{ item.authName }}</span>
        </template>
        <el-menu-item-group>
          <el-menu-item
            :index="'/index/' + items.path"
            v-for="(items, indexs) in item.children"
            :key="indexs"
            ><i class="el-icon-menu"></i>{{ items.authName }}</el-menu-item
          >
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isCollapse: false,
      navList: [],
      arrLcon: [
        "el-icon-user-solid",
        "el-icon-s-platform",
        "el-icon-s-goods",
        "el-icon-s-order",
        "el-icon-s-marketing",
      ],
    };
  },
  methods: {},
  mounted() {
    this.$http.get("menus").then((res) => {
      // console.log(res.data.data);
      this.navList = res.data.data;
    });
  },
};
</script>

<style lang="scss">
.nav {
  height: 100%;
      background-color:#545c64;

  .el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 200px;
    height: 100%;
  }
  .el-checkbox__input {
    display: none;
  }
  .el-checkbox {
    width: 100%;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #4A5064;
  }
  .el-checkbox__label {
    padding: 0;
    color:#fff;
  }
  .el-menu-item {
    display: flex;
    align-items: center;
  }
  el-menu-vertical-demo{
    height: 100%;
  }
}
</style>
